<?php

use Phinx\Migration\AbstractMigration;
use Phinx\Db\Adapter\MysqlAdapter;
class CampManager extends AbstractMigration
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function up()
    {
        $table = $this->table('camp_manager',array('comment' => '营地管理员表'));
        $table
              ->addColumn('branch_id', 'integer', array('limit' => 255, 'comment' => '分公司id'))
              ->addColumn('camp_id', 'integer', array('limit' => 255, 'comment' => '营地id'))
              ->addColumn('login_session_id', 'string', array('limit' => 255, 'comment' => '登录session_id','null' => true))
              ->addColumn('name', 'string', array('limit' => 255, 'comment' => '营地管理员姓名'))
              ->addColumn('phone', 'string', array('limit' => 255, 'comment' => '营地管理员手机号')) 
              ->addColumn('email', 'string', array( 'limit' => 255,'comment' => '营地管理员邮箱'))
              ->addColumn('password', 'string', array( 'limit' => 255,'comment' => '营地管理员密码'))
              ->addColumn('created_at', 'timestamp', array('default' => 'CURRENT_TIMESTAMP'))
              ->addColumn('updated_at', 'timestamp', array('null' => true))
              ->addColumn('status', 'integer', array('limit' => MysqlAdapter::INT_TINY,'comment' => '营地管理员状态'))//超级管理员=0；
              ->addColumn('idnumber', 'string', array( 'limit' => 255,'comment' => '身份证号','null' => true))
              ->addColumn('remark', 'string', array( 'limit' => 255,'comment' => '备注','null' => true))
              ->addIndex('id')
              ->save();   
    }
    public function down()
    {
        $this->dropTable('camp_manager');
    }
}
